package ihm;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import Traduction.RessourceLang;

import composant.panelRetour;
import controleur.mouseLabel;

public class panelIdentification extends JPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ihmFenetre fenetre;
	
	Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
	private JPanel panelLogin = new JPanel();
	private JTextField txtLogin = new JTextField();
	private JPasswordField txtMdp = new JPasswordField();
	private JLabel lblLogin = new JLabel();
	private JLabel lblMdp = new JLabel();
	private JButton btnValider = new JButton();
	private JLabel lblNewAccount = new JLabel();
	
	public panelIdentification(ihmFenetre pFenetre) {
		this.setLayout(null);
		fenetre = pFenetre;
		
		// Configuration du panel d'identification
		panelLogin.setLayout(new GridLayout(6,0,0,5));
		panelLogin.setSize(300,300);
		panelLogin.setLocation(((int)tailleEcran.getWidth()/2-panelLogin.getWidth()/2), ((int)tailleEcran.getHeight()/2-panelLogin.getHeight()/2));
		
		// Parametrage du bouton
		btnValider.setText(RessourceLang.getLabel("panelIdentification.btnVal"));
		
		// Parametrage des JTextField
		txtLogin.setFont(new Font("Arial", Font.PLAIN, 20));
		
		// Valorisation des labels
		lblLogin.setText(RessourceLang.getLabel("panelIdentification.Id"));
		lblMdp.setText(RessourceLang.getLabel("panelIdentification.Mdp"));
		lblNewAccount.setText(RessourceLang.getLabel("panelIdentification.newUser"));
		lblLogin.setFont(new Font("Lucida Console", Font.BOLD, 27));
		lblMdp.setFont(new Font("Lucida Console", Font.BOLD, 27));
		
		// Parametrage des listeners
		lblNewAccount.addMouseListener(new mouseLabel(fenetre, lblNewAccount));
		
		// Add des composants
		panelLogin.add(lblLogin);
		panelLogin.add(txtLogin);
		panelLogin.add(lblMdp);
		panelLogin.add(txtMdp);
		panelLogin.add(btnValider);
		panelLogin.add(lblNewAccount);
		this.add(panelLogin);
		this.add(new panelRetour(fenetre));
		
	}
}
